//
//  YDLunchCell.swift
//  YDOAProduct
//
//  Created by YDWY on 2017/5/26.
//  Copyright © 2017年 Allen. All rights reserved.
//

enum Type : Int {
    case A
    case B
}


import UIKit


class YDLunchCell: UITableViewCell {

    @IBOutlet weak var timeLab: UILabel!//勾餐日期
    @IBOutlet weak var Abtn: UIButton!//A套餐
    @IBOutlet weak var BBtn: UIButton!//B套餐
    
    var callbackWithType : ((_ type:Type ,_ title : String? ,_ id : Int?, _ time : String?) -> Void)? = nil
    
    var model : YDOALunchItemModel!{
        didSet{
            timeLab.text = model.time
            Abtn.setTitle(model.a_can ?? "", for: .normal)
            BBtn.setTitle(model.b_can ?? "", for: .normal)
        }
    }
   
    override func awakeFromNib() {
        super.awakeFromNib()
        self.contentView.backgroundColor = UIColor.clear
        self.backgroundColor = UIColor.clear
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    @IBAction func AbtnClick(_ sender: UIButton) {
        sender.isSelected = true
        BBtn.isSelected = false
        if (callbackWithType != nil) {
             callbackWithType!(.A , sender.currentTitle , model.id , model.time)
        }
        
       
        
    }
    @IBAction func BbtnClick(_ sender: UIButton) {
        sender.isSelected = true
        Abtn.isSelected = false
        if (callbackWithType != nil) {
            callbackWithType!(.B , sender.currentTitle, model.id , model.time)
        }
    }
    
}
